import { LiabilitiesDao } from './../dao/liabilitiesDao'
import { IamInfo } from '../controller/iamInfo'
import { Liabilities } from '../model/liabilities'
import { ResponseList } from '../model/responseList'
export class LiabilitiesService {
  private readonly liabilitiesDao = new LiabilitiesDao()
  queryLiabilityList(params: any): Promise<ResponseList<Liabilities>> {
    params.creator = IamInfo.id
    return this.liabilitiesDao.queryLiabilityList(params).then(modelData => {
      return this.liabilitiesDao.count(params).then(count => {
        const responseList = new ResponseList<Liabilities>();
        responseList.list = modelData
        responseList.count = count
        return responseList
      })
    })
  }
  upsertLiability(params: any): Promise<any> {
    params.creator = IamInfo.id
    params.updater = IamInfo.id
    return this.liabilitiesDao.upsertLiability(params)
  }
  deleteLiability(params: any): Promise<number> {
    return this.liabilitiesDao.deleteLiability(params)
  }
}